package com.sergiandreplace.walkshop.server.servlet.message;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class ResponseMessage {

	private String status;
	private Object content;
	
	public ResponseMessage() {}
	
	public ResponseMessage(String status, String content) {
		this.status=status;
		this.content=content;
	}
	
	public ResponseMessage(String status, Object content) throws JsonGenerationException, JsonMappingException, IOException {
		this.status=status;
		ObjectMapper mapper=new ObjectMapper();
		this.content= content;
	}
	
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Object getContent() {
		return content;
	}
	public void setContent(Object content) {
		this.content = content;
	}
	
	public String toJson() {
		ObjectMapper mapper=new ObjectMapper();
		try {
			return mapper.writeValueAsString(this);
		} catch (Exception e) {
			return null;
		}
	}
	
	
}
